# Contributor: rubicon <rubicon@mailo.com>
# Maintainer:
pkgname=ocaml-lambdasoup
_pkgname=lambdasoup
pkgver=0.7.3
pkgrel=1
pkgdesc="Easy functional HTML scraping and manipulation with CSS selectors"
url="https://github.com/aantron/lambdasoup"
arch="all !riscv64" # restricted by ocaml
license="MIT"
depends="ocaml-runtime"
depends_dev="$pkgname=$pkgver-r$pkgrel"
checkdepends="ocaml-result-dev ocaml-ounit-dev"
makedepends="
	dune
	ocaml
	ocaml-seq-dev
	ocaml-stdlib-shims
	ocaml-uutf-dev
	ocaml-markup-dev
	ocaml-bisect_ppx-dev
	"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/aantron/lambdasoup/archive/$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	export OCAMLPATH=/usr/lib/ocaml
	dune build --root . @install --no-buffer --verbose
}

check() {
	dune runtest --no-buffer --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--prefix=/usr \
		--libdir=/usr/lib/ocaml

	rm -Rf "$pkgdir"/usr/doc
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find usr/lib/ocaml \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
a6f15259e0034f297913fedb2713d4048dcf760d31d00c5ce0a990f977e22aba332a7303dec557912c74c59e178cdfeebfc26703a9698a65f8020aa8222e66e9  ocaml-lambdasoup-0.7.3.tar.gz
"
